home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / 3270XCMD / TNClose.c < prev    next >
Text File  |  1990-03-19  |  1KB  |  81 lines

  1. /* TNClose.c -- XCMD to close the TN3270 driver 
  2.     copyright 1989 Cornell University 
  3. */
  4.  
  5.  
  6. #include <Types.h>
  7. #include <Memory.h>
  8. #include <Devices.h>
  9. #include <HyperXCmd.h>
  10. #include <Errors.h>
  11.  
  12. #include "TNdrvr.h"
  13.  
  14.  
  15. pascal void debugger()    extern 0xA9FF;   
  16.  
  17.  
  18. pascal void TNClose(hycp)
  19. XCmdPtr hycp;
  20. {
  21.     CntrlParam drvpb;
  22.     long * args;
  23.     Str255 pstr;
  24.     
  25.     if (hycp->paramCount != 1) {
  26.         sethand(&hycp->returnValue, "TNClose TNID: need 1 argument");
  27.         return;
  28.     }
  29.     
  30.     HLock((Handle) hycp->params[0]);
  31.     
  32.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  33.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  34.     drvpb.csCode = HTN_CLOSE;
  35.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  36.  
  37.     if (drvpb.ioResult) {
  38.         /* close call failed */
  39.         switch (drvpb.ioResult) {
  40.             case HTNR_NOTN: {
  41.                 sethand(&hycp->returnValue, "TN is not running");
  42.                 break;
  43.             }
  44.             case HTNR_ACTIVE: {
  45.                 sethand(&hycp->returnValue, "TN not opened");
  46.                 break;
  47.             }
  48.             case HTNR_OPEN: {
  49.                 sethand(&hycp->returnValue, "TN has no connection");
  50.                 break;
  51.             }
  52.             case badUnitErr: {
  53.                 sethand(&hycp->returnValue, "TNID is incorrect");
  54.                 break;
  55.             }
  56.             default: {
  57.                 sethand(&hycp->returnValue, "Unknown error");
  58.                 break;
  59.             }
  60.         }
  61.     }
  62.     HUnlock((Handle) hycp->params[0]);
  63.     return;
  64. }
  65.  
  66.  
  67. sethand(thand, str)
  68. Handle * thand;
  69. char * str;
  70. {
  71.     if (*thand == NULL) {
  72.         *thand = NewHandle((Size) 0);
  73.     }
  74.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  75.     strcpy(**thand, str);
  76. }
  77.  
  78.  
  79.  
  80.  
  81. #include <XCmdGlue.inc.c>